@extends('layouts.app')

@section('title', '分类列表')

@section('content')
<div class="container py-4">
    <!-- Page Header -->
    <div class="row mb-4">
        <div class="col-12">
            <h1 class="h2 mb-3">文章分类</h1>
            <p class="text-muted">浏览所有文章分类</p>
        </div>
    </div>

    @if($categories->count() > 0)
        <div class="row g-4">
            @foreach($categories as $category)
                <div class="col-lg-4 col-md-6">
                    <div class="card h-100 shadow-sm">
                        <div class="card-body">
                            <h5 class="card-title">
                                <a href="{{ route('categories.show', $category->slug) }}" class="text-decoration-none">
                                    {{ $category->name }}
                                </a>
                            </h5>
                            
                            @if($category->description)
                                <p class="card-text text-muted">{{ Str::limit($category->description, 100) }}</p>
                            @endif
                            
                            <div class="d-flex justify-content-between align-items-center">
                                <small class="text-muted">
                                    {{ $category->posts->count() }} 篇文章
                                </small>
                                <a href="{{ route('categories.show', $category->slug) }}" class="btn btn-outline-primary btn-sm">
                                    查看文章
                                </a>
                            </div>
                        </div>
                    </div>
                </div>
            @endforeach
        </div>
    @else
        <div class="text-center py-5">
            <h3 class="text-muted">暂无分类</h3>
            <p class="text-muted">还没有创建任何分类</p>
        </div>
    @endif
</div>
@endsection